/**
 * 
 */
package spitfire.ksim.view;

import javax.swing.BoundedRangeModel;
import javax.swing.DefaultBoundedRangeModel;

/**
 * @author Adam
 *
 */
public class KTunersFrame extends KToolFrame{
	private static final long serialVersionUID = 6946757871565583017L;

	public KTunersFrame(final KSimulationView simView) {
		super("Tuners", true, true, true, true);
		setDefaultCloseOperation(HIDE_ON_CLOSE);
		
		BoundedRangeModel refreshPeriodModel = new DefaultBoundedRangeModel(10, 1, 0, 300) {
			private static final long serialVersionUID = -4712633757737271955L;

			@Override
			public int getValue() {
				return (int) (simView.getSimulation().getRefreshPeriod());
			}

			@Override
			public void setValue(int n) {
				simView.getSimulation().setRefreshPeriod(n);
				fireStateChanged();
			}
		};
		add(new KTunerPanel("Refresh", "ms", refreshPeriodModel));
		
//		BoundedRangeModel simTimeModel = new DefaultBoundedRangeModel(10, 1, 0, 1000) {
//			private static final long serialVersionUID = -4712633757737271955L;
//
//			@Override
//			public int getValue() {
//				return (int) (simView.getSimulation().getSimTime());
//			}
//
//			@Override
//			public void setValue(int n) {
//				simView.getSimulation().setSimTime(n);
//			}
//		};
//		add(new KTunerPanel("Refresh", "ms", refreshPeriodModel));
		BoundedRangeModel timeTickModel = new DefaultBoundedRangeModel(60, 1, 1, 360) {
			private static final long serialVersionUID = 3423290540969575363L;

			@Override
			public int getValue() {
				return (int) (simView.getSimulation().getTimeTick() / 1000);
			}

			@Override
			public void setValue(int n) {
				simView.getSimulation().setTimeTick(1000L * n);
				fireStateChanged();
			}
		};
		add(new KTunerPanel("Time tick", "s", timeTickModel));
		
		pack();
	}
}
